import 'package:bobang/pages/home/home_cl.dart';
import 'package:bobang/pages/home/view/home_view.dart';
import 'package:bobang/pages/home/view/product_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class HomeBinding extends Binding {
  @override
  List<Bind> dependencies() {
    return [Bind.lazyPut(() => HomeController())];
  }
}

class HomePage extends GetView<HomeController> {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Obx(() {
        return IndexedStack(
          index: controller.currentIndex.value,
          children: [
            HomeView(),
            ProductView(),
          ],
        );
      }),
      bottomNavigationBar: Obx(() {
        return BottomNavigationBar(
          onTap: (index) => controller.currentIndex.value = index,
          currentIndex: controller.currentIndex.value,
          items: const [
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              label: '首页',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              label: '产品',
            ),
          ],
        );
      }),
    );
  }
}
